#!/bin/bash
# -*- coding: utf-8 -*-

# 默认当前工作路径为 "ns-allinone-3.34/ns-3.34/scratch/"; *** 务必根据提示确认下
currentDir=$(pwd)
echo "\n***\n-current dir is: $currentDir\n-please carefully confirm that it is on 'ns-allinone-3.34/ns-3.34/scratch/'\n***\n"

# 指定数据文件目录 "ns-allinone-3.34/ns-3.34/data/"
dataDir="../data/"

if [ ! -d $dataDir ];then  # 如果没有 ns-allinone-3.34/ns-3.34/data/ 数据文件夹，就创建一个
    mkdir $dataDir
    echo "\n-Notice: 'ns-allinone-3.34/ns-3.34/data/' newly created\n"
else                       # 如果有该文件夹，就间接实现 “删除已有的、旧的仿真数据文件” 的功能
    rm -rf $dataDir
    echo "\n-Notice: 'ns-allinone-3.34/ns-3.34/data/' newly cleaned\n"
    mkdir $dataDir
fi

for Size in $(seq 16 16 1024);  do  # 指定探测报文的大小
    for Hz in $(seq 100 100 1000);  do  # 指定探测报文的发包频率
        echo "\n-*-\n(Probe Packet Size, Probing Frequency): ($Size, $Hz)"
        ../waf --run "E2ePathCongestionDetection --pktSize=$Size --probeHz=$Hz"  # 运行 NS3 仿真
        echo "-NS3- Simulation Completed"
        python flowmon-processing.py -s $Size -f $Hz  # 处理 NS3 流监控数据文件
        echo "-NS3- Flow Monitor Data Processed\n-*-\n"
    done
done

python3 CongestionProbingDataPlot.py